home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / CPP / LONGFI.ZIP / LONG_FIX.H < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-07  |  2.2 KB  |  69 lines

  1. #ifndef LONG_FIXED__H_
  2. #define LONG_FIXED__H_
  3.  
  4. #include <iostream.h>
  5.  
  6. class long_fixed
  7. {
  8.   private:
  9.     unsigned long num[2];
  10.     long_fixed ( const long n0, const long n1 ) { num[0] = n0; num[1] = n1; }
  11.     friend long trunc ( long_fixed num );
  12.  
  13.   public:
  14.    ~long_fixed () { }
  15.  
  16.     long_fixed () {num[0] = num[1] = 0L;}
  17.  
  18.     long_fixed ( const long_fixed &in) {num[0] = in.num[0]; num[1] = in.num[1];}
  19.  
  20.     long_fixed ( const long double in);
  21.     long_fixed ( const double in);
  22.     long_fixed ( const long in);
  23.     long_fixed ( const int in);
  24.  
  25.     long double value(void);
  26.  
  27.     long_fixed operator- ( void ) const;
  28.  
  29.     long_fixed operator+ ( const long_fixed &sec ) const;
  30.     long_fixed operator- ( const long_fixed &sec ) const;
  31.     long_fixed operator* ( const long_fixed &sec ) const;
  32.     long_fixed operator/ ( const long_fixed &sec ) const;
  33.  
  34.     long_fixed operator<< ( const int &shift ) const;
  35.     long_fixed operator>> ( const int &shift ) const;
  36.  
  37.     long_fixed &operator=  ( const long_fixed &sec );
  38.  
  39.     long_fixed &operator+= ( const long_fixed &sec );
  40.     long_fixed &operator-= ( const long_fixed &sec );
  41.     long_fixed &operator*= ( const long_fixed &sec );
  42.     long_fixed &operator/= ( const long_fixed &sec );
  43.  
  44.     long_fixed &operator<<= ( const int &shift );
  45.     long_fixed &operator>>= ( const int &shift );
  46.  
  47.     int  operator<  ( const long_fixed &sec ) const;
  48.     int  operator<= ( const long_fixed &sec ) const;
  49.     int  operator>  ( const long_fixed &sec ) const;
  50.     int  operator>= ( const long_fixed &sec ) const;
  51.     int  operator== ( const long_fixed &sec ) const;
  52.     int  operator!= ( const long_fixed &sec ) const;
  53.  
  54.     friend long_fixed operator* ( long double fst, long_fixed sec);
  55.     friend long_fixed operator/ ( long double fst, long_fixed sec);
  56.     friend long_fixed operator+ ( long double fst, long_fixed sec);
  57.     friend long_fixed operator- ( long double fst, long_fixed sec);
  58.  
  59.     friend long_fixed abs   ( long_fixed num );
  60.  
  61.     friend long round ( long_fixed num );
  62.     friend long ceil  ( long_fixed num );
  63.     friend long floor ( long_fixed num );
  64.  
  65.     friend ostream& operator<< (ostream& os, long_fixed& sec);
  66. };
  67.  
  68. #endif
  69.